package com.nvt.core.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Service;

import com.nvt.core.exception.NvtBusinessException;

@Service
public class HibernateDAOImpl implements IHibernateDAO {

	@Autowired
	private HibernateTemplate hibernateTemplate;

	@Override
	public void executeDelete(Object objectDomain) throws NvtBusinessException {
		try {
			hibernateTemplate.delete(objectDomain);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

	@Override
	public Object executeInsert(Object objectDomain)
			throws NvtBusinessException {
		try {
			return hibernateTemplate.save(objectDomain);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

	@Override
	public void executeUpdate(Object objectDomain) throws NvtBusinessException {
		try {
			hibernateTemplate.update(objectDomain);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

}
